package me.khrystal.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by khrystal on 2015/9/19.
 */
public class Settings {
    public static final String PREF_NAME = "pref_pus";
    public static final String VERSION_KEY = "version_key";

    public static SharedPreferences getPrefs() {
        int code = Context.MODE_MULTI_PROCESS;
        return Global.getContext().getSharedPreferences(PREF_NAME, code);
    }

    public static SharedPreferences.Editor getPrefsEditor() {
        return getPrefs().edit();
    }

    public static void setPatchVersion(int patchVersion) {
        SharedPreferences.Editor edit = getPrefsEditor();
        edit.putInt(VERSION_KEY, patchVersion);
        edit.commit();
    }

    public static int getPatchVersion() {
        SharedPreferences prefs = getPrefs();
        int patchVersion = prefs.getInt(VERSION_KEY,0);
        return patchVersion;
    }
}
